#include "qbullet.h"

QBullet::QBullet(const QString & fileName,QGraphicsScene *scence,qreal angle):QpimapItem(fileName,scence)
{
    qreal dx,dy;
    qreal rad;
    rad=angle*3.14/180;
    dx=120*cos(rad);
    dy=120*sin(rad);

    this->setPos(scence->width()/2+dx,scence->height()-dy);
    this->setRotation(90-angle);

}

void QBullet::advance(int phase)
{
   if(mapToScene(0,0).x()<=0||mapToScene(0,0).x()>=1269)
   {
       delete this;
   }
   else if(this->collidingItems().count())
   {
       docolling();
   }
   else
   {
    this->setPos(mapToScene(0,-20));
   }
}

void QBullet::docolling()
{
    delete this;
}
